package com.hamster.crmpre.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hamster.crmpre.mapper.CompanyAccountMapper;
import com.hamster.crmpre.pojo.CompanyAccount;
import com.hamster.crmpre.service.CompanyAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 公司流水账收支明细的Service
 * @author Tarry
 * @create 2020/1/9 17:42
 */
@Service
public class CompanyAccountServiceImpl implements CompanyAccountService {
    @Autowired
    private CompanyAccountMapper companyAccountMapper;

    @Override
    public Map<String, Object> companyDetails(Date curMonthTime, Date nextMonthTime) {
        Map<String, Object> map = new HashMap<>();
        QueryWrapper<CompanyAccount> companyMoneyQueryWrapper = new QueryWrapper<>();
        companyMoneyQueryWrapper.ge("create_time",curMonthTime).lt("create_time",nextMonthTime);
        companyMoneyQueryWrapper.orderByDesc("create_time");
        List<CompanyAccount> personalMonies = companyAccountMapper.selectList(companyMoneyQueryWrapper);
        Double currentMoney = companyAccountMapper.queryCountMoney(curMonthTime,nextMonthTime);

        map.put("details",personalMonies);
        map.put("currentMoney",currentMoney);
        return map;
    }
}
